<?php

namespace app\exam\validate\admin;

use think\Validate;

/**
 * 试题/题目验证类
 * @package app\exam\validate\admin
 */
class QuestionTopic extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'      => 'require',
        'title'   => 'require',
        'type'    => 'require|in:1,2,3,4,5,6,7,8',
        'bank_id' => 'require|number|gt:0'

    ];

    protected $field = [
        'title' => '题干'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id'            => '操作出错',
        'title.require' => '请输入题干内容',
        'type'          => '请选择试题类型',
        'bank_id'       => '请选择题库'
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create' => ['bank_id', 'type', 'title'],
        'edit'   => ['id', 'type', 'title'],
    ];
}
